package resolver

import (
	"github.com/hashicorp/consul/api"
	"github.com/pkg/errors"
	clientv3 "go.etcd.io/etcd/client/v3"
)

func (b *builder) newEtcdClient(tgt target) (*clientv3.Client, error) {
	cli, err := clientv3.New(*tgt.etcdConfig())
	if err != nil {
		return nil, errors.Wrap(err, "Couldn't connect to the etcd API")
	}
	return cli, nil
}

func (b *builder) newConsulClient(tgt target) (*api.Client, error) {
	cli, err := api.NewClient(tgt.consulConfig())
	if err != nil {
		return nil, errors.Wrap(err, "Couldn't connect to the Consul API")
	}
	return cli, nil
}
